import axios from 'axios';
import Vue from 'vue'
import yz from '../../../models/comm/yz';
export default {

    data() {
        return {
            listLoading: false

        }
    },
    methods: {
        selFile(file, index) {




            this.fileList.forEach(function (file) {
                file.isDefault = false
            }, this);

            file.isDefault = true
            Vue.set(this.fileList, index, file)
            this.$emit('selFile', file);


        },
        getClass(file) {
            if (file.isDefault) {
                return "default"
            }
            else {
                return "noDefault"
            }
        },
        fmtFileList(fileList) {
            fileList.forEach(function (file) {




                if (!file.isDefault) {
                    file.isDefault = false
                }

                file.ext = yz.fileExt(file.url)

                file.isImg = yz.isImg(file.url)


            }, this);
            return fileList
        },
        delFile(file, index) {
            this.fileList.splice(index, 1)

        },
        pageLoad: function (params) {

            this.fmtFileList(this.fileList)
        },
        downFile: function (file) {
            window.open(file.url);

        }


    },
    mounted() {


    },
    props: {
        fileList: {


        }



    },
    watch: {
        fileList: function name(params) {
            this.pageLoad()
        }
    }


}